<?php
class SubmenuWidget extends CWidget
{
	var $adminmenu_id;
	
	var $data = NULL;
	
	public function init()
	{
		// this method is called by CController::beginWidget()
		$this->data = array();
	}
	
	public function run()
	{
		// this method is called by CController::endWidget()
		$controller = $this->getController();
		$module = $controller->getModule();

		$adminmenu = adminmenu::model()->find(array(
			"condition" => "route = '".$module->getId()."'"
		));
		
		$this->adminmenu_id = $adminmenu->id;
		
		$menuitem_array = adminmenu::model()->findAll(array(
			"condition"=>"enable = 1 AND parent_id = " . $this->adminmenu_id,
			"order" => "`order` ASC"
		));

		$this->data["menuitem_array"] = $menuitem_array;
		
		$this->render("submenu", $this->data);
	}
}